--赏金任务
local shangjinrenwu = fk.CreateSkill {
    name = "mcdh_shangjinrenwu"
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

shangjinrenwu:addEffect(fk.TargetConfirming,{
    can_trigger = function(self, event, target, player, data)
        local room = player.room
        if player:hasSkill(self) and player:getMark("mcdh_charge") >= 2 and (data.card.trueName == "slash" or data.card:isCommonTrick()) and data:isOnlyTarget(target) and target.hp <= player.hp and data.from ~= player then
            if target ~= player and data.use.from:canUseTo(data.card,player,{bypass_distances=true,bypass_times=true}) then
                return target ~= data.from
            else
                return target ~= data.from and not data.from:isKongcheng()
            end
        end
    end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        if target.id ~= player.id then
            return room:askForSkillInvoke(player, self.name, data,"#shangjinrenwu-invoke1::"..target.id..":"..data.card.name)
        else
            return room:askForSkillInvoke(player, self.name, data,"#shangjinrenwu-invoke2::"..data.from)
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        lib.LoseCharge(player,player,2,self.name)
        if target ~= player then
            player:drawCards(2,self.name)
            data:cancelTarget(target)
            data:addTarget(player)
        else
            local id = room:askForCardChosen(player, data.from, "h", self.name)
            room:obtainCard(player,id, false, fk.ReasonPrey,player ,self.name)
        end
    end
})

Fk:loadTranslationTable {
    ["mcdh_shangjinrenwu"] = "赏金任务",
    [":mcdh_shangjinrenwu"] = "蓄力技(2)，当体力值不大于你的角色成为另一名其他角色使用的【杀】或普通锦囊牌的唯一目标时：若你不为此牌目标，则你可以摸两张牌并将此牌目标转为你；若你为此牌目标，你可以获得此牌使用者的一张手牌。",
    ["#shangjinrenwu-invoke1"] = "赏金任务:摸两张牌并将目标为 %dest 的 %arg 转移给自己",
    ["#shangjinrenwu-invoke2"] = "赏金任务:获得 %dest 一张手牌"
}

return shangjinrenwu